/*
 * Copyright (c) 2010 CCX(China) Co.,Ltd. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * CCX(China) Co.,Ltd. ("Confidential Information").
 * It may not be copied or reproduced in any manner without the express 
 * written permission of CCX(China) Co.,Ltd.
 *
 * Author: zhaosj
 * Date: 2010-8-30 上午10:33:34
 */
package com.webservice;

/**
 * @author Administrator
 *
 */
import java.io.FileOutputStream;

public class ComplexTypeService {
	
	// 上传图像，imageByte参数表示上传图像文件的字节，
	// length参数表示图像文件的字节长度（该参数值可能小于imageByte的数组长度）
	public boolean uploadImageWithByte(byte[] imageByte, int length) {
		FileOutputStream fos = null;
		try {
			// 将上传的图像保存在D盘的test1.jpg文件中
			fos = new FileOutputStream("d:\\test1.jpg");
			// 开始写入图像文件的字节
			fos.write(imageByte, 0, length);
			fos.close();
		} catch (Exception e) {
			return false;
		} finally {
			if (fos != null) {
				try {
					fos.close();
				} catch (Exception e) {

				}
			}
		}
		return true;
	}

	// 返回一维字符串数组
	public String[] getArray() {
		String[] strArray = new String[] { "自行车", "飞机", "火箭" };
		return strArray;
	}

	// 返回二维字符串数组
	public String[] getMDArray() {
		String[] strArray = new String[] { "自行车,飞机,火箭", "中国,美国,德国", "超人,蜘蛛侠,钢铁侠" };
		return strArray;
	}

	// 返回DataForm类的对象实例
	public DataForm getDataForm() {
		return new DataForm();
	}

	// 将DataForm类的对象实例序列化，并返回序列化后的字节数组
	public byte[] getDataFormBytes() throws Exception {
		java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
		java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(baos);
		oos.writeObject(new DataForm());
		return baos.toByteArray();
	}
}
